<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3-5编写代码实现两个数的比较</title>
    <script src="https://unpkg.com/vue@3"></script>
</head>
<body>
    <div id="app">
        <p>
            <label>请输入第一个数：</label>
            <input type="text" v-model="num1">
        </p>
        <p>
            <label>请输入第二个数：</label>
            <input type="text"  v-model="num2">
        </p>
        <p>
            <button @click="cal">比较</button>
            <p>得出结果：{{ res }}</p>
        </p>
    </div>
    <script>
        const { createApp } = Vue;
        createApp({
            data() {
                return {
                    num1:0,
                    num2:0,
                    res:'',
                };
            },
            methods: {
                cal(){
                    let n1 = parseInt(this.num1)
                    let n2 = parseInt(this.num2)
                    if(n1==n2){
                        this.res = "相等"
                    }else if(n1>n2){
                        this.res = "第一个数大于第二个数"
                    }else{
                        this.res = "第一个数小于第二个数"
                    }
                }
            },
        }).mount("#app");
    </script>
</body>
</html>